<template>
  <div class="dashboard-container">
    <div>
      <el-card class="box-card">
        这是主页面

        <div>
          <!-- <img
            src="dev-api/web/image?model=res.partner&id=&field=image_128&ss=1"
          /> -->
          <!-- <img src="dev-api/web/image/357" />
          <img
            src="dev-api/web/image?model=res.partner&id=10&field=image_1920"
          />
          <img
            src="dev-api/web/image?model=hr.employee&id=4&field=image_1920"
          /> -->
        </div>
        <div>
          <div v-for="rec in records" :key="rec.id">
            <div v-for="fld in Object.keys(rec)" :key="fld">
              {{ fld }}, {{ rec[fld] }}
            </div>
            <div>--------</div>
          </div>
        </div>

        <!-- {{ userinfo }} -->
      </el-card>
    </div>
  </div>
</template>

<script>
// import odoo from '@/odooapi'
import odoo from '@/odooapi'

import request from '@/utils/request'

export default {
  name: 'Dashboard',
  components: {},
  data() {
    return {
      records: [],
      userinfo: {}
    }
  },
  computed: {},
  async created() {
    this.test()
  },

  mounted() {},

  methods: {
    async test() {
      const fields = {
        user_input_line_ids: {
          question_id: null,
          value_suggested: null
        }
      }
      const model = 'survey.user_input'
      const Model = odoo.env(model)

      const res = await Model.browse_one(2, { fields })
      console.log('xxxx, odoo: ', res)
    },

    async test9() {
      // const baseURL = process.env.VUE_APP_BASE_API
      // const imgUrl = '/web/image'
      // //
      // // console.log('xxx2', this)
      // const self = this
      // setTimeout(function() {
      //   const ss2 = new Date()
      //   const ss = ss2.getTime()
      //   self.img_url = `${self.base_img_url}&ss=${ss}`
      //   self.img_url2 = `${self.base_img_url2}&ss=${ss}`
      //   self.test()
      // }, 6000)
    },

    async test8() {
      console.log('home request', request)
      request({
        url: `/get/params`,
        method: 'get',
        params: { id2: 1, name: '2333' }
      })
      request({
        url: `/post/params`,
        method: 'post',
        params: { id: 1, name: '2333' }
      })

      request({
        url: `/get/data`,
        method: 'get',
        data: { id23333333data: 1, name: '2333' }
      })

      request({
        url: `/post/data`,
        method: 'post',
        data: { login: 'MyUsername', password: 'myPsw' }
      })

      request({
        url: `/get/all`,
        method: 'get',
        params: { id2: 1, name: '2333' },
        data: { id23333333data: 1, name: '2333' }
      })

      request({
        url: `/post/all`,
        method: 'post',
        params: { id: 1, name: '2333' },
        data: { login: 'MyUsername', password: 'myPsw' }
      })
    },
    async test7() {
      const model = 'res.partner'
      const method = 'search_read2'
      const args = []
      const kwargs = {
        feilds: { name: null }
      }
      const ss = await odoo.rpc.call(model, method, args, kwargs)
      console.log('odoo', ss)
    },

    async test6() {
      const model = 'res.partner'
      const method = 'search_read2'
      const args = []
      const kwargs = {
        feilds: { name: null }
      }
      const ss = await odoo.rpc.call2(model, method, args, kwargs)
      console.log('odoo', ss)
    },

    async test5() {
      //
      const ss = await odoo.rpc.login2({
        username: '用户1',
        password: '123456'
      })
      console.log('odoo', ss)
    },

    async test4() {
      const model = 'res.partner'
      const Model = odoo.env(model)

      const res = await Model.search_read({ fields: ['name'] })
      console.log('xxxx, odoo res: ', res)

      const res2 = await Model.search_count({ id___gt: 3 })
      console.log('xxxx, odoo count: ', res2)
    },

    async test3() {
      const model = 'res.partner'
      const Model = odoo.env(model)

      console.log('xxxx, odoo: ', Model)

      const res = await Model.search_read({ fields: ['name'] })
      console.log('xxxx, odoo: ', res)

      const res2 = await Model.env('res.users').search_read({
        fields: ['name']
      })
      console.log('xxxx, odoo: ', res2)
    },

    async test2() {
      const model = 'res.partner'
      const method = 'search'
      const args = [[]]
      const kwargs = {}

      const res = await odoo.call(model, method, args, kwargs)
      console.log('xxxx, odoo: ', res)
    }
  }
}
</script>
<style></style>
